//
//  NoticeView.m
//  ShrimpCrowdordering
//
//  Created by 骆锴 on 2018/8/25.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "NoticeView.h"

@implementation NoticeView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.shadowBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        self.shadowBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        self.shadowBtn.alpha = 1;
        [self.shadowBtn addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.shadowBtn];
        
        UIView *baseview = [[UIView alloc] initWithFrame:CGRectMake(ScreenX375(38), ScreenX375(196), ScreenX375(300), ScreenX375(200))];
        baseview.layer.cornerRadius = 6.0;
        baseview.backgroundColor = [UIColor whiteColor];
        
        
        _noticeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(50), ScreenX375(60), ScreenX375(200), ScreenX375(12))];
        _noticeLabel.textColor = REXADECIMALCOLOR(@"#212121");
        [baseview addSubview:_noticeLabel];
        
        UIButton *close = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(277), ScreenX375(10), ScreenX375(13), ScreenX375(13))];
        [close setBackgroundImage:[UIImage imageNamed:@"评论叉"] forState:UIControlStateNormal];
        [close addTarget:self action:@selector(hidden) forControlEvents:UIControlEventTouchUpInside];
        [baseview addSubview:close];
        
        UIButton *Button = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(100), ScreenX375(126), ScreenX375(100), ScreenX375(34))];
        [Button setTitle:@"立即绑定" forState:UIControlStateNormal];
        [Button setTitleColor:REXADECIMALCOLOR(@"#ffffff") forState:UIControlStateNormal];
        [Button addTarget:self action:@selector(done) forControlEvents:UIControlEventTouchUpInside];
        Button.titleLabel.font = Kfont(18);
        [Button setBackgroundImage:[UIImage imageNamed:@"按钮背景"] forState:UIControlStateNormal];
        Button.layer.cornerRadius = 17;
        Button.clipsToBounds = YES;
        [baseview addSubview:Button];
        
        [self addSubview:baseview];
        
        return self;
    }
}

-(void)setNotice:(NSString *)notice{
    self.noticeLabel.text = notice;
}

-(void)hidden{
    if (_hiddenClick) {
        _hiddenClick();
    }
}

-(void)done{
    if (_doneClick) {
        _doneClick();
    }
}
@end
